# Maintainer: David Runge <dvzrv@archlinux.org>

_name=pytest-services
pkgname=python-pytest-services
pkgver=2.2.1
pkgrel=9
pkgdesc="Services plugin for pytest testing framework"
arch=(any)
url="https://github.com/pytest-dev/pytest-services"
license=(MIT)
depends=(python-pytest python-requests python-psutil python-zc.lockfile)
makedepends=(python-build python-installer python-setuptools python-setuptools-scm python-toml python-wheel)
checkdepends=(memcached python-astroid python-coverage python-mysqlclient python-pylibmc xorg-server-xvfb)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('b711c08482938d23fad9996741367281a0550552d83a2b2d2482f9a38919a8c277e33a856f612bd11c8d432465e47c4233ad50004b0defb174dc31425e5fd226')
b2sums=('5a8ff780045e314a4128012aa1d9d8dfa3a4c864dd4dcb694cccc4568edd9ddb94dcc6bcbfceaf8f4d96fd821b4252dcac622c4b84fcb62c0655673d088cb444')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir="tmp_install" dist/*.whl
  export PYTHONPATH="$PWD/tmp_install/$_site_packages/:$PYTHONPATH:$PWD/tests"
  pytest -vv -k 'not test_mysql'
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 {AUTHORS,CHANGES,README}.rst -t "$pkgdir/usr/share/doc/$pkgname/"
  install -vDm 644 LICENSE.txt -t "$pkgdir/usr/share/licenses/$pkgname/"
}
